if(NOT TARGET format)
  cpmaddpackage(
    NAME format #
    VERSION 1.7.0 #
    SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Format.cmake" #
  )
endif()

if(NOT TARGET google-test)
  cpmaddpackage(
    NAME google-test #
    VERSION 1.14.0 #
    # URL "https://github.com/google/googletest/archive/refs/tags/v1.17.0.zip" #
    URL "https://gitee.com/mirrors/googletest/repository/archive/main.zip" #
  )
  # 强制使用动态链接库
  set(gtest_force_shared_crt
    ON
    CACHE BOOL "" FORCE)
endif()

if(NOT TARGET eigen)
  cpmaddpackage(
    NAME eigen #
    VERSION 3.4.0 #
    URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz" #
    DOWNLOAD_ONLY ON #
  )
  # Eigen 不支持 CMake，自定义头文件接口目标
  if(eigen_ADDED)
    add_library(eigen INTERFACE)
    add_library(Eigen3::Eigen ALIAS eigen)
    target_include_directories(eigen SYSTEM INTERFACE ${eigen_SOURCE_DIR})
  endif()
endif()

if(NOT TARGET glm)
  cpmaddpackage(
    NAME glm #
    VERSION 3.4.0 #
    URL "https://gitee.com/mirrors/glm/repository/archive/master.zip" #
  )
  set(GLM_BUILD_LIBRARY 
  ON
    CACHE BOOL "" FORCE)
endif()

# if(NOT TARGET spdlog)
#   cpmaddpackage(
#     NAME spdlog #
#     VERSION 1.15.3 #
#     URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz" #
#     DOWNLOAD_ONLY ON #
#   )
#   if(spdlog_ADDED)
#     add_library(spdlog INTERFACE)
#     target_include_directories(spdlog SYSTEM INTERFACE ${spdlog_SOURCE_DIR}/include)
#   endif()
# endif()
